package com.leo.springbootmultithreadbasic.lock.reentrantlock.fairandunfair;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Leo
 * @version V1.0
 * @date 2021/11/3 11:15 PM
 */
public class RunUnFair {

    private  static Logger logger = LoggerFactory.getLogger(RunUnFair.class);


    public static void main(String[] args) {
        final MyService myService = new MyService(false);

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                logger.info("The Thread {} 运行了", Thread.currentThread().getName());
                myService.testGetLock();
            }
        };

        // 创建线程
        Thread[] threadArray = new Thread[10];
        for (int i = 0; i < 10; i++) {
            threadArray[i] = new Thread(runnable);
        }

        // 启动线程
        for (int i = 0; i < 10; i++) {
            threadArray[i].start();
        }

    }
}
